diff options
| author | Adam Soltys <[email protected]> | 2026-03-04 23:06:35 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-04 23:06:35 -0800 |
| commit | e5f37b003d93a17c2a9958697269b2d3228d8830 (patch) | |
| tree | e2c3a3c4d1bec48d323e830f5be35d5832845a9a /src/routes/(app)/send/ark/[address]/+layout.server.ts | |
| parent | e6882c6a8987e23215a2538b242431ae603c7101 (diff) | |
| download | coinos-ui-e5f37b003d93a17c2a9958697269b2d3228d8830.tar.gz coinos-ui-e5f37b003d93a17c2a9958697269b2d3228d8830.zip | |
tuning
Diffstat (limited to 'src/routes/(app)/send/ark/[address]/+layout.server.ts')
| -rw-r--r-- | src/routes/(app)/send/ark/[address]/+layout.server.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/routes/(app)/send/ark/[address]/+layout.server.ts b/src/routes/(app)/send/ark/[address]/+layout.server.ts index 6381463a..18fb7aed 100644 --- a/src/routes/(app)/send/ark/[address]/+layout.server.ts +++ b/src/routes/(app)/send/ark/[address]/+layout.server.ts @@ -1,11 +1,18 @@ import { auth, get } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, params, parent }) { +export async function load({ cookies, params, parent, url }) { const { user } = await parent(); - const aid = cookies.get("aid") || user.id; + let aid = url.searchParams.get("aid") || cookies.get("aid") || user.id; const { address, amount } = params; - const { balance } = await get(`/account/${aid}`, auth(cookies)); + let account = await get(`/account/${aid}`, auth(cookies)); + + // Fall back to custodial if cookie points to ark account + if (account.type === "ark" && aid !== user.id) { + aid = user.id; + account = await get(`/account/${aid}`, auth(cookies)); + cookies.set("aid", aid, { path: "/", maxAge: 86400, httpOnly: false }); + } let invoice; try { @@ -21,5 +28,5 @@ export async function load({ cookies, params, parent }) { if (recipient?.id !== user.id && recipient.id === invoice.aid) redirect(307, r); } - return { balance }; + return { balance: account.balance }; } |
